/* ************************************************************************** */ 
/* Example of a syndication feed reader using the Project Rome API with       */ 
/* BSF4ooRexx                                                                 */ 
/* current version of Rome: rome1.0.jar            https://rome.dev.java.net/ */ 
/* You need to implement this API plus the JDOM API                           */ 
/* jdom.jar  ,   you can find this at               https://jdom.org/        ; */ 
/*                                                                            */ 
/* This is a simple example of how to create a syndication feed with ooRexx   */                
/* created by Martin Stoppacher     date:   26.12.2009    (c) 2009            */ 
/* license:ÊÊÊÊLGPL 3.0ÊÊÊÊÊÊÊused versions: Java 1.6, ooRexx 4.0, Bsf4ooRexx */
/*             (Lesser Gnu Public License version 3.0),                       */ 
/*             cf. <http://www.gnu.org/licenses/lgpl.html>                    */ 
/* ************************************************************************** */ 

say "hello this creates a syndfeeds" 

--pull typet  /* optional type input */
typet = "atom_0.3" 
fileName = "test6_new_feed" typet 

/*                              converting the rexx date() to an other format */ 
datum = date() 
parse var datum day mounth year 
if mounth="Dec" then mounth=12 
if mounth="Jan" then mounth=01 
if mounth="Feb" then mounth=01              /*  simply add the necessary once */ 
datum_new = year"-"mounth"-"day 
say "Todays date: " datum_new 

call Syssleep 1 

say 'Your crated feed starts hear :' 

feed=.bsf~new("com.sun.syndication.feed.synd.SyndFeedImpl") 
/*      using syndfeedImpl to creat a feed using the independent object model */ 
feed~setFeedType(typet) 
/*                                                 sets the type of this feed */ 

desc = "My favorite webpages; format:_" typet 
 
feed~setTitle("This is a simple Sample") 
feed~setDescription(desc) 
feed~setAuthor("Martin Stoppacher") 
feed~setLink("http://martinstoppacher.com") 
feed~setLanguage("English") 

/*        create a java  SimpleDateFormat instance for entry~setPublishedDate */ 
DATE_PARSER = .bsf~new("java.text.SimpleDateFormat", "yyyy-MM-dd") 

/*                       creates a Java array list for the entries of the feed*/ 
entries =.bsf~new("java.util.ArrayList") 
entry =.bsf~new("com.sun.syndication.feed.synd.SyndEntryImpl") 

/*                                       add some entries to an entriy object */ 
entry~setTitle("The Project Rome Web Page") 
entry~setPublishedDate(DATE_PARSER~parse(datum_new)) 
entry~setLink("https://rome.dev.java.net/") 
entry~setUri("https://rome.dev.java.net/") 
entry~setAuthor("dev.java.net") 

/*                     create a independent description content implemetation */ 
description=.bsf~new("com.sun.syndication.feed.synd.SyndContentImpl") 
description~setType("text/plain") 
description~setValue("ROME Web Page") 
entry~setDescription(description)      
/*                             add the description object to the entry object */ 

/* create a new category; by adding the SyndCategoryImpl to a Java array      */ 
/* object and  this array object to the entry object                          */ 
cat =.bsf~new("java.util.ArrayList") 
category=.bsf~new("com.sun.syndication.feed.synd.SyndCategoryImpl") 
category~setName("Java") 
category~setTaxonomyUri("https://rome.dev.java.net/") 
cat~add(category) 
entry~setCategories(cat) 

/*                             add the entry to the Java entries array object */ 
entries~add(entry) 

/*                                                            a secound entry */ 
entry =.bsf~new("com.sun.syndication.feed.synd.SyndEntryImpl") 

entry~setTitle("Java 1.4 Documentation") 
entry~setPublishedDate(DATE_PARSER~parse(datum_new)) 
entry~setLink("http://java.sun.com/j2se/1.4.2/docs/api/") 
entry~setUri("http://java.sun.com/") 
entry~setAuthor("java.sun.com/") 

description=.bsf~new("com.sun.syndication.feed.synd.SyndContentImpl") 
description~setType("text/plain") 
description~setValue("Documentation of the Java 1.4 API") 
entry~setDescription(description) 

cat =.bsf~new("java.util.ArrayList") 
category=.bsf~new("com.sun.syndication.feed.synd.SyndCategoryImpl") 
category~setName("Documentation") 
category~        setTaxonomyUri("http://java.sun.com/j2se/1.4.2/docs/api/") 
cat~add(category) 
entry~setCategories(cat) 

entries~add(entry) 

feed~setEntries(entries) 
/*                                 sets the Java array as entries of the feed */ 

/*                                                                writer part */ 
writer=.bsf~new("java.io.FileWriter",fileName) 
output=.bsf~new("com.sun.syndication.io.SyndFeedOutput") 
output~output(feed,writer) 
writer~close() 

say output~outputString(feed,1) -- usage of pretty print(0 yes or 1 no)

PP : RETURN "[" || ARG(1)|| "]" 
::requires BSF.cls